<template>
	<view class="unstacking-instore-step2-page-content">
		<easy-select-form-item
			class="forma-item"
			label="入库方式"
			v-model="form.taskModel"
			:list="selectList.models"
			value-field="code"
			label-field="name"
			:clearable="false"
		/>
		
		<easy-select-form-item
			class="forma-item"
			label="入库区域"
			v-model="form.taskArea"
			:list="selectList.areas"
			:clearable="false"
		/>
		
		<easy-select-form-item
			class="forma-item"
			label="起始站点"
			v-model="form.stationCode"
			:list="selectList.startStations"
			value-field="stationCode"
			label-field="stationName"
		/>
		
		<scan-input-form-item
			label="目标位置"
			v-model="form.toPlaceCode"
			:has-scan="false"
			:has-search="false"
		/>
	</view>
</template>

<script>
import ScanInputFormItem from '@/components/ScanInputFormItem.vue'
import EasySelectFormItem from '@/components/EasySelectFormItem.vue'
import { getDicList } from '@/static/js/utils/index.js'
const defaultForm = {
	stationCode:'',
	taskModel:'2',
	taskArea:2,
	toPlaceCode:''
}
export default {
	name:'unstackingInstoreStep2PageContent',
	components:{ScanInputFormItem,EasySelectFormItem},
	data(){
		return {
			form: {...defaultForm},
			selectList:{
				startStations:[],
				models:[],
				areas:[
					{value:1,label:'一楼检验点'},
					{value:2,label:'二楼钢平台'}
				]
			}
		}
	},
	methods:{
		init(){
			this.getStartStations()
			this.getActionTypes()
		},
		getStartStations(callback){
			if (this.selectList.startStations.length>0) {
				callback && callback(true)
			} else {
				this.$api.get('StarPlaceList',{},{block:'unstacking'}).then((d)=>{
					this.selectList.startStations = d || []
					callback && callback(true)
				}).catch((e)=>{
					callback && callback(false,e)
				})
			}
		},
		getActionTypes(){
			if (this.selectList.models.length>0) {
				callback && callback(true)
			} else {
				this.selectList.models = getDicList(this.$store,'assemble_taskmodel')
			}
		},
		clear(){
			this.form = {...defaultForm}
		},
		get(){
			return {...this.form}
		}
	}
}
</script>

<style lang="scss" scoped>
.unstacking-instore-step2-page-content{
	height: 100%;
	overflow: auto;
	.forma-item{
		margin-bottom: 24rpx;
	}
}
</style>